home *** CD-ROM | disk | FTP | other *** search
- /* Main alarm routine(s) for EngClock */
-
- //#include <proto/exec.h>
- #include <intuition/intuition.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- //#include <proto/intuition.h>
-
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
-
- extern void msg(char *msg);
- extern BOOL talk(char *text);
- extern BOOL playsam(char *esvxname);
- extern char *trans(char *text);
- extern char *findday(int preset2);
- extern void gettime(void);
-
- extern int memmins, memhours;
- extern char *engnums[60];
- extern char *days_data[7];
-
- extern struct IntuiText req_text;
- extern struct IntuiText ok_text;
-
- struct Event {
- BOOL used;
- int type; /* Type of event */
- int hours; /* Time of event */
- int minutes;
- int timecode;
- char message[256];
- int day;
- int month;
- int year;
- BOOL enabledate;
- int freq;
- };
-
- extern struct {
- /* Prefs structure used for preferences file format */
-
- char header[10]; /* I.D. Header */
- int vers; /* Version of preferences file */
- int x; /* X dimension of window when saved */
- int y; /* Y dimension of window when saved */
- int width; /* Width of window when saved */
- int height; /* Height of window when saved */
- int planguage; /* Language selected (menu) when saved, low pri */
- int just; /* Justification of text, 0=Left, 1=Centre */
- short date; /* Display date?, 0 = No, 1=Yes */
- short wtf; /* Window to front? */
- int time_col[8];
- int date_col[8];
- short autoadjust; /* Auto adjust ? */
- char backdrop[256];
- char pub[139];
- char accent[256]; /* Language file for tRanslate */
- char tkey[100];
- char hkey[100];
- struct Event events[11]; /* For the alarm! */
- }prefs;
-
- extern struct {
- /* Time structure, set up by gettime() and used globally */
-
- int hours; /* Number of hours since midnight on system clock */
- int seconds; /* Number of seconds */
- int minutes; /* Number of minutes */
- int years; /* Current year */
- int days; /* Date in current month */
- int months; /* Current month */
- int wday; /* Day in the week 0-6 (starting Sunday) */
- }time;
-
-
- void process_alarm(void) {
- int i; BOOL flg=FALSE;
-
-
-
- /* Re-init the time structure */
- gettime();
-
- for(i=1; i<=10; i++) {
- if(prefs.events[i].used) {
- if(!prefs.events[i].enabledate)
- flg=TRUE;
- else {
- switch(prefs.events[i].freq) {
- case 0: /* Daily */
- flg=TRUE;
- break;
- case 1: /* Once */
- if(prefs.events[i].day==time.days) {
- if(prefs.events[i].month==time.months) {
- if(prefs.events[i].year==time.years) {
- flg=TRUE;
- }
- }
- }
- break;
- case 2: /* Weekly */
- if(!strcmp(findday(i),days_data[time.wday]))
- flg=TRUE;
- break;
- case 3: /* Monthly */
- if(prefs.events[i].day==time.days)
- flg=TRUE;
- break;
- case 4: /* Yearly */
- if(prefs.events[i].day==time.days) {
- if(prefs.events[i].month==time.months) {
- flg=TRUE;
- }
- }
- break;
- default:
- break;
- }
- }
- if(prefs.events[i].minutes==time.minutes) {
- if(prefs.events[i].hours==time.hours) {
- if(flg) {
- if(!(time.minutes==memmins && time.hours==memhours)) {
- switch(prefs.events[i].type) {
- case 0: /* Req */
- req_text.IText=prefs.events[i].message;
- ok_text.IText="Sure!";
- AutoRequest(NULL,&req_text,NULL,&ok_text,NULL,NULL,320,100);
- break;
- case 1: /* Sound */
- playsam(prefs.events[i].message);
- break;
- case 2: /* Command */
- system(prefs.events[i].message);
- break;
- case 3: /* Talk */
- talk(trans(prefs.events[i].message));
- break;
- default:
- msg("Unknown event type!");
- break;
- }
- }
- }
- }
- }
- }
- flg=FALSE; /* Remeber to set this back again dickbrains */
- }
- memmins=time.minutes;
- memhours=time.hours;
- }
-